package com.ssy.lingxi.pay.entity;

import com.ssy.lingxi.pay.handler.converter.JpaJsonToPayProveBOConverter;
import com.ssy.lingxi.pay.model.bo.PayProveBO;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 授信交易记录表
 * @author 伍将
 * @date 2020/8/21
 * @version 2.0.0
 */
@Entity
@Table(schema = "public", name = "pay_credit_trade_record",
        indexes = {@Index(name = "pay_credit_trade_record_credit_id_idx", columnList = "creditId"),
                @Index(name = "pay_credit_trade_record_bill_id_idx", columnList = "billId"),
                @Index(name = "pay_credit_trade_record_is_temp_idx", columnList = "isTemp")})
public class CreditTradeRecordDO implements Serializable {
    private static final long serialVersionUID = -7551884472458386921L;

    /**
     * 交易记录id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "credit_trade_record_seq")
    @SequenceGenerator(sequenceName = "pay_credit_trade_record_seq", name = "credit_trade_record_seq", allocationSize = 1)
    private Long id;

    /**
     * 授信id
     */
    @Column(columnDefinition = "int8")
    private Long creditId;

    /**
     * 账单id
     */
    @Column(columnDefinition = "int8")
    private Long billId;

    /**
     * 交易流水号
     */
    @Column(columnDefinition = "varchar(20)")
    private String tradeCode;

    /**
     * 订单编码
     */
    @Column(columnDefinition = "varchar(50)")
    private String orderCode;

    /**
     * 交易时间
     */
    @Column(columnDefinition = "int8")
    private Long tradeTime;

    /**
     * 交易金额
     */
    @Column(columnDefinition = "decimal")
    private Double tradeMoney;

    /**
     * 交易类型： 1-线上，2-线下
     */
    @Column(columnDefinition = "int")
    private Integer tradeType;

    /**
     * 交易渠道： 1-微信，2-支付宝，3-银联，4-授信
     */
    @Column(columnDefinition = "int")
    private Integer tradeChannel = 99;

    /**
     * 交易项目: 1-订单支付, 2-订单退款, 3-还款
     */
    @Column(columnDefinition = "int")
    private Integer operation;

    /**
     * 状态: 1-待确认还款结果, 2-确认未到账, 3-确认到账
     */
    @Column(columnDefinition = "int")
    private Integer status;

    /**
     * 备注
     */
    @Column(columnDefinition = "varchar(500)")
    private String remark;

    /**
     * 支付证明
     */
    @Convert(converter = JpaJsonToPayProveBOConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<PayProveBO> payProveList;

    /**
     * 是否为临时数据:0-否，1-是
     */
    @Column(columnDefinition = "int default 0")
    private Integer isTemp = 0;

    public Integer getIsTemp() {
        return isTemp;
    }

    public void setIsTemp(Integer isTemp) {
        this.isTemp = isTemp;
    }

    public String getOrderCode() {
        return orderCode;
    }

    public void setOrderCode(String orderCode) {
        this.orderCode = orderCode;
    }

    public Integer getTradeType() {
        return tradeType;
    }

    public void setTradeType(Integer tradeType) {
        this.tradeType = tradeType;
    }

    public Integer getTradeChannel() {
        return tradeChannel;
    }

    public void setTradeChannel(Integer tradeChannel) {
        this.tradeChannel = tradeChannel;
    }

    public List<PayProveBO> getPayProveList() {
        return payProveList;
    }

    public void setPayProveList(List<PayProveBO> payProveList) {
        this.payProveList = payProveList;
    }

    public Long getBillId() {
        return billId;
    }

    public void setBillId(Long billId) {
        this.billId = billId;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getCreditId() {
        return creditId;
    }

    public void setCreditId(Long creditId) {
        this.creditId = creditId;
    }

    public String getTradeCode() {
        return tradeCode;
    }

    public void setTradeCode(String tradeCode) {
        this.tradeCode = tradeCode;
    }

    public Long getTradeTime() {
        return tradeTime;
    }

    public void setTradeTime(Long tradeTime) {
        this.tradeTime = tradeTime;
    }

    public Double getTradeMoney() {
        return tradeMoney;
    }

    public void setTradeMoney(Double tradeMoney) {
        this.tradeMoney = tradeMoney;
    }

    public Integer getOperation() {
        return operation;
    }

    public void setOperation(Integer operation) {
        this.operation = operation;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
}
